-
Notifications
You must be signed in to change notification settings - Fork 473
Update AppThemeResourceExtension to not use IProvideParentValues #2639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Updates AppThemeResourceExtension to remove its reliance on the internal IProvideParentValues interface by introducing a custom resource lookup that leverages IProvideValueTarget, IRootObjectProvider, and application‐level resources.
- Replaced the
RequireServiceattribute to useIProvideValueTargetandIRootObjectProvider. - Reimplemented
ProvideValueto search resources via visual tree traversal, root object, then application resources. - Added
TryFindResourceInVisualElementhelper and adjusted exception messages; also fixed a typo inAppThemeObject.shared.cs.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/CommunityToolkit.Maui/Extensions/AppThemeResourceExtension.shared.cs | Swap out IProvideParentValues dependency and implement new lookup logic |
| src/CommunityToolkit.Maui/Essentials/AppTheme/AppThemeObject.shared.cs | Corrected spelling in XML doc comment (diffent → different) |
Comments suppressed due to low confidence (1)
src/CommunityToolkit.Maui/Extensions/AppThemeResourceExtension.shared.cs:88
- The summary only mentions visual tree traversal, but the method also checks the element itself for
IResourcesProviderand supportsResourceDictionarylookups. Update the doc comment to accurately describe all lookup paths.
/// Attempts to locate a resource by walking up the visual tree from a target object.
src/CommunityToolkit.Maui/Extensions/AppThemeResourceExtension.shared.cs
Show resolved
Hide resolved
TheCodeTraveler
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Gerald!
Description of Change
This PR updates
AppThemeResourceExtensionto not useIProvideParentValues, which is internal to .NET MAUI.At the .NET MAUI side we're exploring to remove the InternalsVisibleTo for the Toolkit since it shouldn't be necessary.
Most APIs there will be removed with the Popup v2 implementation (yay), the rest are being used in AvatarView and we're OK to make those public on the .NET MAUI side for .NET 10, but the one used in
AppThemeResourceExtensionwe're not OK with making public.Therefore, this PR explores an alternative implementation that does not use
IProvideParentValues